package com.ruoyi.project.tool.exception.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.db.tool.domain.SysExceptionLog;
import com.ruoyi.db.tool.domain.query.SysExceptionLogQueryVo;
import com.ruoyi.project.tool.exception.service.SysExceptionLogService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 异常日志记录Controller
 *
 * @author ruoyi
 * @date 2020-04-01
 */
@Api(tags="tool管理：异常日志记录管理")
@RestController
@RequestMapping("/tool/exceptionlog")
public class SysExceptionLogController extends BaseController
{
    @Autowired
    private SysExceptionLogService sysExceptionLogService;

    @ApiOperation("查询异常日志记录列表")
    @PreAuthorize("@ss.hasPermi('tool:exceptionlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysExceptionLogQueryVo exceptionLogQueryVo)
    {
        startPage();
        List<SysExceptionLog> list = sysExceptionLogService.selectSysExceptionLogList(exceptionLogQueryVo);
        return getDataTable(list);
    }

    @ApiOperation("导出异常日志记录列表")
    @Log(title = "异常日志记录", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('tool:exceptionlog:export')")
    @GetMapping("/export")
    public AjaxResult export(SysExceptionLogQueryVo exceptionLogQueryVo)
    {
        List<SysExceptionLog> list = sysExceptionLogService.selectSysExceptionLogList(exceptionLogQueryVo);
        ExcelUtil<SysExceptionLog> util = new ExcelUtil<SysExceptionLog>(SysExceptionLog.class);
        return util.exportExcel(list, "exceptionlog");
    }

    @ApiOperation("获取异常日志记录详细信息")
    @Log(title = "异常日志记录", businessType = BusinessType.OTHER)
    @PreAuthorize("@ss.hasPermi('tool:exceptionlog:query')")
    @GetMapping(value = "/{operId}")
    public AjaxResult getInfo(@PathVariable("operId") Long operId)
    {
        return AjaxResult.success(sysExceptionLogService.selectSysExceptionLogById(operId));
    }

    @ApiOperation("删除异常日志记录")
    @Log(title = "异常日志记录", businessType = BusinessType.DELETE)
    @PreAuthorize("@ss.hasPermi('tool:exceptionlog:remove')")
	@DeleteMapping("/{operIds}")
    public AjaxResult remove(@PathVariable Long[] operIds)
    {
        return toAjax(sysExceptionLogService.deleteSysExceptionLogByIds(operIds));
    }
}
